package com.test.demo.controller;

import com.test.demo.dao.BookDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class AppRunner implements CommandLineRunner {
    private Logger logger=LoggerFactory.getLogger(AppRunner.class);

    private  final BookDao bookDao;

    public AppRunner(BookDao bookDao1){
        this.bookDao = bookDao1;
    }

    @Override
    public void run(String... args) throws Exception {
        logger.info(".... Fetching books");
        logger.info("isbn-1234 -->" + bookDao.getBookByIbsn("isbn-1234"));
        logger.info("isbn-4567 -->" + bookDao.getBookByIbsn("isbn-4567"));
        logger.info("isbn-1234 -->" + bookDao.getBookByIbsn("isbn-1234"));
        logger.info("isbn-4567 -->" + bookDao.getBookByIbsn("isbn-4567"));
        logger.info("isbn-1234 -->" + bookDao.getBookByIbsn("isbn-1234"));
        logger.info("isbn-1234 -->" + bookDao.getBookByIbsn("isbn-1234"));
    }
}
